<template>
  <div class="home">
    <!-- 轮播图 -->
    <el-carousel trigger="click" height="350px">
      <el-carousel-item><img src="../assets/carousel1.jpg" /></el-carousel-item>
      <el-carousel-item><img src="../assets/carousel2.jpg" /></el-carousel-item>
      <el-carousel-item><img src="../assets/carousel3.jpg" /></el-carousel-item>
    </el-carousel>
    <!-- 主体内容 -->
    <section class="section-content">
      <div class="section-box">
        <div class="box-card-left">
          <el-card>
            <div class="title">
              <span @click="doDetailHandler" class="title-content">优秀开源项目、ddfgdgdgdfgdfg博客、书籍整理</span>
            </div>
            <div class="user-info">
              <span>
                <i class="el-icon-user-solid"></i>
                FengJianxin
              </span>
              <span>
                <i class="el-icon-timer"></i>
                2020/2/23
              </span>
              <span>
                <i class="el-icon-collection-tag"></i>
                openresty网关
              </span>
            </div>
          </el-card>
          <el-card v-for="item in 10" :key="item">
            <div class="title">
              <span class="title-content">优秀开源项目、博客、书籍整理</span>
            </div>
            <div class="user-info">
              <span>
                <i class="el-icon-user-solid"></i>
                FengJianxin
              </span>
              <span>
                <i class="el-icon-timer"></i>
                2020/2/23
              </span>
              <span>
                <i class="el-icon-collection-tag"></i>
                openresty网关
              </span>
            </div>
          </el-card>
        </div>
        <el-card class="box-card-right">
          <div class="category">
            <div class="category-box" v-for="item in 10" :key="item">
              <div>架构实战</div>
              <div>12</div>
            </div>
          </div>
          <div class="tag">
            <div class="tag-span">SDFSF</div>
            <div class="tag-span">胜</div>
            <div class="tag-span">胜负</div>
            <div class="tag-span">胜多负少</div>
            <div class="tag-span">s打发</div>
            <div class="tag-span">sdfzsdfs</div>
            <div class="tag-span">胜多负少</div>
            <div class="tag-span">说是</div>
            <div class="tag-span">SDssfdfFSF</div>
            <div :style="{ backgroundColor: randColor() }" v-for="item in 30" :key="item" class="tag-span">性能{{ item / 3 }}</div>
          </div>
        </el-card>
      </div>
    </section>
  </div>
</template>

<script>
export default {
  data() {
    return {}
  },
  methods: {
    randColor() {
      return `rgb(${Math.floor(Math.random() * 255)},${Math.floor(Math.random() * 255)},${Math.floor(Math.random() * 255)})`
    },
    doDetailHandler() {
      this.$router.push({ path: '/detail' })
    },
  },
}
</script>

<style scoped>
.section-content {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}
.section-box {
  width: 70%;
  display: flex;
  justify-content: space-between;
}
.box-card-left {
  width: 76%;
}
.box-card-right {
  width: 23%;
}
.el-card:hover {
  box-shadow: 5px 5px 15px #ccc;
}

.section-content .title {
  color: #242424;
  font-size: 22px;
}
.section-content .user-info {
  color: #7f7f7f;
  margin-top: 10px;
}
.section-content .user-info span {
  margin-right: 10px;
}

.box-card-left .el-card {
  margin-bottom: 10px;
}
.box-card-left .el-card:hover {
  cursor: pointer;
}

.title-content {
  position: relative;
}
.title-content::after {
  content: '';
  width: 0;
  height: 2px;
  background-color: green;
  position: absolute;
  top: 35px;
  left: 50%;
}
.title-content:hover {
  color: green;
}
.title-content:hover::after {
  width: 100%;
  transition: 2s;
  left: 0px;
}

.category-box {
  width: 100%;
  height: 40px;
  padding: 8px;
  box-sizing: border-box;
  margin-bottom: 10px;
  box-shadow: 2px 2px 15px #ccc;
  border-radius: 5px;
  position: relative;
  cursor: pointer;
}
.category-box:hover {
  transform: scale(1.05);
}

.category-box div:last-child {
  width: 30px;
  height: 30px;
  background: red;
  color: white;
  border-radius: 5px;
  line-height: 30px;
  text-align: center;
  position: absolute;
  top: 5px;
  right: 15px;
}

.tag-span {
  padding: 3px 15px;
  color: white;
  border-radius: 5px;
  margin-right: 10px;
  display: inline-block;
  margin-bottom: 10px;
}
</style>
